<!doctype html>
<html lang="en">
<head>
    <title>Grid - Templating</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="Overview" />
    <meta name="keywords" content="" />
    <meta name="author" content="ComponentOne" />

    <link href="../../themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" />
    <link href="../../themes/wijmo/jquery.wijmo-open.2.3.2.css" rel="stylesheet" type="text/css" />
    <link href="../../themes/wijmo/jquery.wijmo.wijpager.css" rel="stylesheet" type="text/css" />
    <link href="../../themes/wijmo/jquery.wijmo.wijgrid.css" rel="stylesheet" type="text/css" />

    <script src="../../external/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../../external/jquery-ui-1.9.1.custom.min.js" type="text/javascript"></script>
    <script src="../../external/globalize.min.js" type="text/javascript"></script>
    <script src="../explore/js/jquery.tmpl.min.js" type="text/javascript"></script>
    <script src="../../external/jquery.mousewheel.min.js" type="text/javascript"></script>

    <script src="../../external/jquery.wijmo-open.all.2.3.2.min.js" type="text/javascript"></script>
    <script src="../../wijmo/jquery.wijmo.wijpager.js" type="text/javascript"></script>
    <script src="../../wijmo/jquery.wijmo.wijdatasource.js" type="text/javascript"></script>
    <script src="../../wijmo/jquery.wijmo.wijgrid.js" type="text/javascript"></script>

    <script type="text/javascript">
        function getMovies(pageIndex) {
            var pageSize = 20;

            $("#demo tbody")
              .fadeOut("medium", function () {
                  $.ajax({
                      url: "http://odata.netflix.com/Catalog/Genres('Sci-Fi & Fantasy')/Titles",
                      data: {
                          $format: "json",
                          $inlinecount: "allpages",
                          $skip: pageIndex * pageSize,
                          $top: pageSize
                      },
                      dataType: "jsonp",
                      jsonp: "$callback",
                      success: showMovies
                  });
              });
        }

        function showMovies(data) {
            $("#movieTmpl").tmpl(data.d.results).appendTo("#demo tbody");

            $("#demo").wijgrid({
                allowSorting: true,
                allowPaging: true,
                pageSize: 10,
                columns: [
                    {},
                    {},
                    {},
                    {},
                    { dataType: "number" }
                ]
            });
        }
    </script>
    <script id="scriptInit" type="text/javascript">
        $(document).ready(function () {
            getMovies(0);
        });
    </script>
    <script id="movieTmpl" type="text/x-jquery-tmpl">
        <tr>
            <td><img src="${BoxArt.SmallUrl}" /></td>
            <td>${Name}</td>
            <td>${Rating}</td>
            <td>${ReleaseYear}</td>
            <td>${AverageRating}</td>
        </tr>
    </script>
</head>
<body class="demo-single">
    <div class="container">
        <div class="header">
            <h2>
                Templating</h2>
        </div>
        <div class="main demo">
            <!-- Begin demo markup -->
            <table id="demo">
                <thead>
                    <tr>
                        <th>
                            Box
                        </th>
                        <th>
                            Name
                        </th>
                        <th>
                            Rated
                        </th>
                        <th>
                            Year
                        </th>
                        <th>
                            Rating
                        </th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
            <!-- End demo markup -->
            <div class="demo-options">
                <!-- Begin options markup -->
                <!-- End options markup -->
            </div>
        </div>
        <div class="footer demo-description">
            <p>
                This sample demonstrates how to create a template for the wijgrid widget.
            </p>
        </div>
    </div>
</body>
</html>
